/******************************init****************************/
function query_td(page) {
	var parm = $('#queryForm').serialize() + (page != null ? ('&page=' + page) : '');
	var url = create_url('topicDifficulty-query');
	sys_record_parm('topicDifficulty',parm);
	sys_loading();
	$.ajax({type:'POST', url:url, data:parm,
		success: function(result) {
			sys_loading_close();
			$('#tdResultList').html(result);
		}
	});
}


function shield_td(code, name) {
	$.Zebra_Dialog('确定是否屏蔽'+ name + ' 课程吗？',{
	'type': 'question',
	'title': '警告' ,
	'buttons':[
       {caption:'屏蔽',callback:function() {
    	   var url = create_url('topicDifficulty-shield');
    	   aidExecute_td(code, url);
		}},
       {caption:'取消',callback:function(){}
       }]
	});
}

function unshield_td(code, name) {
	$.Zebra_Dialog('确定要给'+ name + ' 课程解除屏蔽吗？',{
	'type': 'question',
	'title': '警告' ,
	'buttons':[
       {caption:'解除',callback:function() {
    	   var url = create_url('topicDifficulty-unshield');
    	   aidExecute_td(code, url);
		}},
       {caption:'取消',callback:function(){}
       }]
	});
}
function aidExecute_td(code, url) {
	var parm = {'code':code};
	sys_submiting();
	$.ajax({type:'POST', url:url, data:parm,
		success: function(result) {
			sys_submiting_close();
			if ('success' == result) {
				query_td();
			} else {
				sys_msg('操作失败，请刷新页面再次尝试，如果问题依然存在，请联系管理员!');
			}
		}
	});
}
/*************edit*****************/
function save_td() {
	var v = $('#name').val();
	if (v == null || v == '') {
		sys_msg('难度不能为空');
		return false;
	}
	var parm = $('#editForm').serialize();
	var url = create_url('topicDifficulty-save');
	sys_submiting();
	$.ajax({type:'POST', url:url, data:parm,
		success: function(result) {
		sys_submiting_close();
			if ('success' == result) {
				sys_msg('操作成功!');
				sys_load_handle('topicDifficulty');
			}else if('exists' == result){
				sys_msg('名称重复!');
			}else{
				sys_msg('操作失败!');
			}
		}
	});
}